package com.yc.navy.goods.service.lmpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.navy.goods.bean.ClassInfo;
import com.yc.navy.goods.bean.TypeInfo;
import com.yc.navy.goods.dto.TypeDTO;
import com.yc.navy.goods.dto.TypeInfoDTO;
import com.yc.navy.goods.enums.ResultEnum;
import com.yc.navy.goods.mapper.ITypeInfoMapper;
import com.yc.navy.goods.service.ITypeInfoService;
import com.yc.navy.goods.util.FindByPageParamUtil;
import com.yc.navy.goods.util.StringUtil;
import com.yc.navy.goods.vo.StreamVO;

@Service
public class TypeInfoServiceImpl implements ITypeInfoService {
	@Autowired
	private ITypeInfoMapper typeInfoMapper;

	@Override
	public List<TypeInfoDTO> finds() {
		return typeInfoMapper.finds();
	}

	@Override
	public int add(TypeInfo tf) {
		if(StringUtil.checkNull(tf.getPic(),tf.getTname())) {
			return -1;
		}
		return typeInfoMapper.add(tf);
	}

	@Override
	public StreamVO findByPageForBack(Map<String, Object> map) {
		List<TypeInfo> list = typeInfoMapper.findByPage(FindByPageParamUtil.StreamVOfindByPageParam(map));
		if(list == null || list.isEmpty()) {
			return new StreamVO(ResultEnum.NOTFOUND);
		}
		
		return new StreamVO(list,typeInfoMapper.total());
	}

	@Override
	public int updateStatue(TypeInfo tf) {
		if(StringUtil.checkNull(tf.getTid(),tf.getTstatus())) {
			return -1;
		}
		return typeInfoMapper.updateStatue(tf);
	}

	@Override
	public int delete(int tid) {
		if(StringUtil.checkNull(tid)) {
			return -1;
		}
		return typeInfoMapper.delete(tid);
	}

	@Override
	public List<ClassInfo> findclass() {
		return typeInfoMapper.findclass();
	}

	@Override
	public List<TypeDTO> findsitems() {
		return typeInfoMapper.findsitems();
	}

}
